import sys

KEYWORD = "　"

filename = "最新县及县以上行政区划代码.txt"


def filtering(level, specialized=()):
    items = []
    with open(filename) as f:
        for line in f:
            if line.count(KEYWORD) == level:
                print(line.strip())
                items.append(line.strip().split())
    return items

while True:
    level = int(input('level?(1:省级/2:地级/3:县级)'))
    print(repr(level))
    items = filtering(level)
    sqls = []
    if level == 1:
        for item in items:
            sql = "INSERT INTO districts VALUES (DEFAULT, uuid_nil(), '{1}', '{0}', 1);".format(*item)
            sqls.append(sql)
            #break
    print("\n".join(sqls))
    break
